//
//  ArtworkViewContoller.m
//  EmilyCarrGradCatolog
//
//  Created by Miles on 10-03-25.
//  Copyright 2010 Miles Thorogood
//  greenmeat.net. All rights reserved.
//

#import "ArtworkViewContoller.h"
#import "Artist.h"

#define IMAGE_VIEW_TAG 456

@implementation ArtworkViewContoller

@synthesize scrollView, artist ;
/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	UIImage *img = [artist.artistImage valueForKey:@"artistImage"];
	
	UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
	imgView.tag = IMAGE_VIEW_TAG ;
	imgView.userInteractionEnabled = NO;
	
	// Set up the main scroller as our content
	UIScrollView *contentView = [[UIScrollView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]];
	[contentView setScrollEnabled:YES];
	[contentView setContentSize:[img size]];
	[contentView setMaximumZoomScale: 2.0f];
	[contentView setMinimumZoomScale: 0.5f];
	[contentView setDelegate:self];
	
	[contentView addSubview:imgView];
	[imgView release];
	
	self.view = contentView;
    [contentView release];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
	return [self.view viewWithTag:IMAGE_VIEW_TAG];
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
